package no.sachmuld.methodcombination.api.reflection.component;

import no.sachmuld.methodcombination.api.MethodInvocation;
import org.apache.log4j.Logger;

import java.lang.reflect.Method;

/**
 *
 */
public class AuxiliaryMethodInvocation implements MethodInvocation {

    private static Logger logger = Logger.getLogger(AuxiliaryMethodInvocation.class);

    private Object targetObject;
    private Method method;
    private Object[] parameters;

    public AuxiliaryMethodInvocation(Object targetObject, Method method, Object[] parameters) {
        this.targetObject = targetObject;
        this.method = method;
        this.parameters = parameters;
    }

    @Override
    public Object proceed() {
        logger.warn("Warning: calling proceed() in an auxiliary method has no effect");
        return null;
    }

    @Override
    public Object getThis() {
        return targetObject;
    }

    @Override
    public Method getMethod() {
        return method;
    }

    @Override
    public Object[] getArguments() {
        return parameters;
    }
}
